package net.pessu.android.shoppoid.gui;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.LinearLayout;

public class ButtonListLayout extends LinearLayout {

	public ButtonListLayout(Context context) {
		super(context);
	}

	public ButtonListLayout(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	public void initializeButtons() {
		ButtonList currentButton;
		for (int i = 0; i < getChildCount(); i++) {
			currentButton = (ButtonList) getChildAt(i);
			currentButton.unSelect();
		}
	}

	public double getSelectedButtonTaux() {
		ButtonList currentButton;
		for (int i = 0; i < getChildCount(); i++) {
			currentButton = (ButtonList) getChildAt(i);
			if (currentButton.isSelected()) {
				return currentButton.getTaux();
			}
		}
		return 0.0;
	}

	public void selectButton(double taux) {
		ButtonList currentButton;
		for (int i = 0; i < getChildCount(); i++) {
			currentButton = (ButtonList) getChildAt(i);
			if (currentButton.getTaux() == taux) {
				currentButton.select();
			}
		}
	}

}
